import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../router/navigator_util.dart';
import '../../share/my_color.dart';
import '../../share/my_font.dart';


class ShowBottomSheet {
  //分享提示框--选择相机等，类似于ios里面的 sheet
  static Future<int?> showSheet(
    BuildContext context, {
    String? title,
    String? message,
    List<String>? actions,
    required String cancleString,
  }) async {
    assert(
        actions != null || title != null || message != null || cancleString != null,
        'An action sheet must have a non-null value for at least one of the following arguments: '
        'actions, title, message, or cancelButton');
    if (actions == null) actions = [];
    List<CupertinoActionSheetAction> actionList = List.generate(actions.length, (index) {
      return CupertinoActionSheetAction(
        onPressed: () {
          NavigatorUtil.pop<int>(context,index +1);

        },
//        isDestructiveAction: false,
        child: Text(
          actions![index],
          style: TextStyle(
            color: MyColors.color_34_34_34,
            fontWeight: FontWeight.w500,
            fontSize: MyFont.font16,
          ),
        ),
      );
    });

    CupertinoActionSheetAction cancleButton = CupertinoActionSheetAction(
      onPressed: () {
        NavigatorUtil.pop<int>(context,0);
      },
      child: Text(
        cancleString,
        style: TextStyle(
          color: MyColors.color_34_34_34,
          fontWeight: FontWeight.w500,
          fontSize: MyFont.font16,
        ),
      ),
    );

    Future<int?> future = showCupertinoModalPopup(
      context: context,
      builder: (ctx) {
        return CupertinoActionSheet(
          title: title == null ? null : Text(title),
          message: message == null ? null : Text(message),
          actions: (actions!.isEmpty || actions == null) ? null : actionList,
          cancelButton: cancleString == null ? null : cancleButton,
        );
      },
    );
    return future;
  }

}
